function getUserName() {
    var userName = getCookie('userName');
    if (userName == '' || userName == null ) {
        $('.head .tool a').text('登录');
        $('.head .tool a').attr('href', mmssm_url + 'login.jsp');
    } else {
        $('.head .tool a').text('欢迎,' + userName);
        $('.head .tool a').attr('title', '点击进入巡察系统');
        $('.head .tool a').attr('href', mmssm_url + 'static/html/index.html');
    }
}

$(function () {
    getUserName();
    var tpxw_swiper = new Swiper('.tpxw-swiper', {
        loop: false,
        pagination: {
            el: '.tpxw-pagination',
            type: 'custom',
            renderCustom: function (swiper, current, total) {
                $('.tpxw .tpxw-pagination span').removeClass('swiper-active-switch');
                $('.tpxw .tpxw-pagination span:nth-child(' + (current) +  ')').addClass('swiper-active-switch');
            }
        },
        autoplay: {
            delay: 2000,
            stopOnLastSlide: false,
            disableOnInteraction: true,
        },
    });
    
    $('.tpxw .tpxw-pagination span').click(function () {
        var index = $(this).data('index');
        $('.tpxw .tpxw-pagination span').removeClass('swiper-active-switch');
        $('.tpxw .tpxw-pagination span:nth-child(' + (index + 1) +  ')').addClass('swiper-active-switch');
        tpxw_swiper.slideTo(index, 1000, false);//切换到第index个slide，速度为1秒
    });
});

